The Geometric Shape Types
QuickDraw GX provides eight types of geometric shapes: empty shapes, full shapes, point shapes, line shapes, curve shapes, rectangle shapes, polygon shapes, and path shapes.The following sections examine each of these shape types in detail. In particular, these sections discuss how the different types of shapes use their geometry and shape fill properties, and what the default values are for properties of each type of shape.
Empty Shapes and Full Shapes
Empty shapes and full shapes are the only geometric shapes with no information stored in the geometry property.An empty shape is a shape with no geometry. When you draw an empty shape, nothing appears. You can use an empty shape when creating other types of shapes. For example, you can create an empty shape and then build it into a polygon shape, adding one contour at a time.
A full shape is a shape that covers the largest area possible. When you draw a full shape, QuickDraw GX fills in the entire drawable area of the full shape's view port (paying attention to the clipping information stored in the full shape's transform). You can use a full shape when erasing an area.
Point Shapes
The point shape is the simplest of the geometric shapes. Its geometry consists of a single geometric point--a single (x, y) coordinate pair.Point shapes must always have the open-frame shape fill or the no-fill shape fill.
A point shape's style determines how QuickDraw GX draws the point. If a point's style has a pen width of 0, which is the default pen width, QuickDraw GX draws the point as a single pixel on the output device. If the style has a pen width greater than 0, QuickDraw GX draws the point only if the style also has a start cap. The next chapter, "Geometric Styles," discusses these aspects of the style object in more detail.
When you create a new point shape, QuickDraw GX makes a copy of the default point shape. The default point shape has these properties:
You may change the properties of the default point shape, which effectively changes the behavior of the functions that create point shapes. However, when creating a new point shape, QuickDraw GX always initializes the owner count to 1 and the geometry to (0.0, 0.0), even if you have specified other values for the default point shape.
- owner count: 1
- tag list: no tags
- shape attributes: no attributes
- shape type: point type
- shape fill: open-frame fill
- geometry: (0.0, 0.0)
For examples of creating and drawing point shapes, see "Creating and Drawing Points" beginning on page 2-29.
Line Shapes
The geometry of a line shape consists of two geometric points: a first point and a last point. Because the points are ordered, a line points in a certain direction.Line shapes must always have the open-frame shape fill or the no-fill shape fill.
Figure 2-8 shows two line shapes. The geometries of these two lines have the same geometric points, but in the opposite order. Therefore, the two lines point in opposite directions.
If a line shape uses the default style information, the direction of the line does not affect how QuickDraw GX draws the line. However, when you add stylistic variations (such as pen width, pen placement, and dashes) to a line shape, the direction of the line can affect how QuickDraw GX draws the line. See the next chapter, "Geometric Styles," for information about how you can add stylistic variations to a line.
When you create a new line shape, QuickDraw GX makes a copy of the default line shape. The default line shape has these properties:
You may change the properties of the default line shape, which effectively changes the behavior of the functions that create line shapes. However, when creating a new line shape, QuickDraw GX always initializes the owner count to 1 and the geometry to (0.0, 0.0), (0.0, 0.0), even if you have specified other values for the default line shape.
- owner count: 1
- tag list: no tags
- shape attributes: no attributes
- shape type: line type
- shape fill: open-frame fill
- geometry: (0.0, 0.0), (0.0, 0.0)
For examples of creating and drawing line shapes without stylistic variations, see "Creating and Drawing Lines" beginning on page 2-36.
For examples of creating and drawing lines with stylistic variations, see the next chapter, "Geometric Styles."
Curve Shapes
The geometry of a curve shape consists of three geometric points: a first point, a last point, and an off-curve control point that determines the tangents of the curve. The curve described by these three points is a quadratic Bézier curve--the same type of curve used to describe TrueType fonts.Because a curve's geometric points are ordered, a curve has direction. As with line shapes, direction affects the drawing of a curve only after you apply stylistic variations, which are discussed in the next chapter, "Geometric Styles."
Curve shapes must always have the open-frame shape fill or no fill shape fill.
Figure 2-9 shows an example of a curve shape. In this example, the first point is (50.0, 50.0), the last point is (200.0, 50.0) and the off-curve control point is (100.0, 150.0).
Figure 2-9 A quadratic Bézier curve
Quadratic Bézier curves have the following characteristics:
Figure 2-10 Finding the midpoint of a curve
- A line connecting the first point and the off-curve control point describes the tangent of the curve at the first point.
- A line connecting the off-curve control point and the last point describes the tangent of the curve at the last point.
- The curve is always contained by the triangle formed by the three geometric points.
- The midpoint of the curve is halfway between the off-curve control point and the point midway between the first point and last point, as shown in Figure 2-10.
You can divide a quadratic Bézier curve into two smaller quadratic Bézier curves:
Figure 2-11 shows a curve divided into two smaller curves.
- One smaller curve extends from the first point to the midpoint of the original curve. The new off-curve control point is the point midway between the first point and the original off-curve control point.
- The other smaller curve extends from the midpoint to the last point of the original curve. The new off-curve control point is the point midway between the original off-curve control point and the last point.
Figure 2-11 Dividing a curve into two smaller curves
When you create a new curve shape, QuickDraw GX makes a copy of the default curve shape. The default curve shape has these properties:
You may change the properties of the default curve shape, which effectively changes the behavior of the functions that create curve shapes. However, when creating a new curve shape, QuickDraw GX always initializes the owner count to 1 and the geometry to (0.0, 0.0), (0.0, 0.0), (0.0, 0.0), even if you have specified other values for the default curve shape.
- owner count: 1
- tag list: no tags
- shape attributes: no attributes
- shape type: curve type
- shape fill: open-frame fill
- geometry: (0.0, 0.0), (0.0, 0.0), (0.0, 0.0)
For examples of creating and drawing curve shapes without stylistic variations, see "Creating and Drawing Curves" beginning on page 2-41.
For examples of creating and drawing curves with stylistic variations, see the next chapter, "Geometric Styles."
Rectangle Shapes
The geometry of a rectangle shape consists of two geometric points. Typically, these geometric points represent the upper-left and lower-right corners of the rectangle; however, you can specify any corner as the first geometric point and the diagonally opposite corner as the second geometric point.Rectangle shapes can have any shape fill except the open-frame shape fill.
Figure 2-12 shows a rectangle geometry and how that rectangle is drawn with a closed-frame shape fill and how it is drawn with an even-odd shape fill.
Figure 2-12 A rectangle geometry shown framed and filled
When you create a new rectangle shape, QuickDraw GX makes a copy of the default rectangle shape. The default rectangle shape has these properties:
- Note
- Although you may specify a rectangle's geometric points in any order, QuickDraw GX functions that calculate rectangles always return rectangles with the upper-left corner as the first geometric point and the lower-right corner as the second geometric point.
![]()
You may change the properties of the default rectangle shape, which effectively changes the behavior of the functions that create rectangle shapes. However, when creating a new rectangle shape, QuickDraw GX always initializes the owner count to 1 and the geometry to (0.0, 0.0), (0.0, 0.0), even if you have specified other values for the default rectangle shape.
- owner count: 1
- tag list: no tags
- shape attributes: no attributes
- shape type: rectangle type
- shape fill: even-odd fill
- geometry: (0.0, 0.0), (0.0, 0.0)
For examples of creating and drawing rectangle shapes without stylistic variations, see "Creating and Drawing Rectangles" beginning on page 2-43.
For examples of creating and drawing rectangles with stylistic variations, see the next chapter, "Geometric Styles."
Polygon Shapes
A polygon contour is a series of geometric points connected by straight lines. A polygon shape may include any number of polygon contours.
Polygon shapes may have any shape fill.
- Implementation Note
- In version 1.0 of QuickDraw GX, a single polygon contour can have between 1 and 32,767 geometric points. The geometry of a polygon shape can have between 0 and 32,767 polygon contours. The total size of a polygon geometry may not exceed 2,147,483,647 bytes.
![]()
Figure 2-13 shows a polygon shape that contains two separate contours. The shape is shown four times:
Figure 2-13 A polygon shape with two polygon contours
- as a polygon shape geometry
- as drawn with the open-frame shape fill
- as drawn with the closed-frame shape fill
- as drawn with even-odd shape fill
The first contour in Figure 2-13 has four geometric points and the second contour has three geometric points.
The index of a geometric point within its contour is called its contour index. The geometric points in the first contour in Figure 2-13 have contour indexes ranging from 1 to 4, and the geometric points in the second contour in Figure 2-13 have contour indexes ranging from 1 to 3. These contour indexes are shown in the top part of the figure.
Since contours and geometric points are ordered, each geometric point can be numbered from the first geometric point of the first contour to the last geometric point of the last contour. This number is called a geometric point's geometry index. Since the polygon geometry in Figure 2-13 has seven geometric points total, these points have geometry indexes ranging from 1 to 7. You use geometry indexes and contour indexes of geometric points when editing polygon geometries. For examples, see "Editing Polygon Parts" beginning on page 2-82.
If the contours of a polygon shape cross over one another, or if a polygon shape contains contours that lie within other contours, the even-odd shape fill and the winding shape fill may fill the polygon shape differently, as shown in Figure 2-14.
Figure 2-14 A polygon drawn with the even-odd and winding shape fills
When you create a new polygon shape, QuickDraw GX makes a copy of the default polygon shape. The default polygon shape has these properties:
You may change the properties of the default polygon shape, which effectively changes the behavior of the functions that create polygon shapes. However, when creating a new polygon shape, QuickDraw GX always initializes the owner count to 1 and the geometry to 0 contours with 0 points, even if you have specified other values for the default polygon shape.
- owner count: 1
- tag list: no tags
- shape attributes: no attributes
- shape type: polygon type
- shape fill: even-odd fill
- geometry: 0 contours, 0 points
For examples of creating and drawing polygon shapes without stylistic variations, see "Creating and Drawing Polygons" beginning on page 2-45.
For examples of creating and drawing polygons with stylistic variations, see the next chapter, "Geometric Styles."
Path Shapes
A path contour, like a polygon contour, is defined by a series of geometric points. However, a path contour can contain off-curve control points as well as on-curve points; therefore, a path contour can contain curves as well as straight lines. A path shape may include any number of path contours.
Every path contains an array of control bits that specify which geometric points are on curve and which geometric points are off curve. QuickDraw GX connects two consecutive on-curve points with a straight line. If two on-curve points have an off-curve point between them, QuickDraw GX connects the two on-curve points with a quadratic Bézier curve, using the geometric point between them as the off-curve control point.
- Implementation Note
- In version 1.0 of QuickDraw GX, a single path contour can have between 0 and 32,767 geometric points. The geometry of a path shape can between 0 and 32,767 polygon contours. The total size of a path geometry may not exceed 2,147,483,647 bytes.
![]()
QuickDraw GX allows a path to have two or more consecutive off-curve control points. In this case, each pair of consecutive off-curve points implies an on-curve point midway between them, as represented by the small hollow circle in Figure 2-15.
Figure 2-15 A path with two consecutive off-curve points
Path shapes may have any shape fill--including open-frame shape fill. However, a path may not have the open-frame shape fill if the first point or the last point of any path contour is an off-curve point.
If the contours of a path shape cross over one another, or if a path shape contains contours that lie within other contours, the even-odd shape fill and the winding shape fill may fill the path shape differently, as shown in Figure 2-16.
Figure 2-16 A path shape filled with the even-odd and winding shape fills
Contour direction affects how QuickDraw GX fills a path when the path has the winding shape fill. In the example in Figure 2-16, if the inner contour has the opposite contour direction from the outer contour, the winding shape fill works in the same manner as the even-odd shape fill. For more information, see the next section, "Shape Fill." For examples, see "Creating and Drawing Paths" beginning on page 2-55.
When you create a new path shape, QuickDraw GX makes a copy of the default path shape. The default path shape has these properties:
You may change the properties of the default path shape, which effectively changes the behavior of the functions that create path shapes. However, when creating a new path shape, QuickDraw GX always initializes the owner count to 1 and the geometry to 0 contours with 0 points, even if you have specified other values for the default paths shape.
- owner count: 1
- tag list: no tags
- shape attributes: no attributes
- shape type: path type
- shape fill: even-odd fill
- geometry: 0 contours, 0 points
For examples of creating and drawing path shapes without stylistic variations, see "Creating and Drawing Paths" beginning on page 2-55.
For examples of creating and drawing paths with stylistic variations, see the next chapter, "Geometric Styles."
Main | Page One | What's New | Apple Computer, Inc. | Find It | Contact Us | Help